```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java异常详解：ExceptionInInitializerError</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .serif {
            font-family: 'Noto Serif SC', serif;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .code-block {
            background-color: #282c34;
            border-radius: 8px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
        }
        .link-underline {
            position: relative;
        }
        .link-underline:after {
            content: '';
            position: absolute;
            width: 0;
            height: 2px;
            bottom: -2px;
            left: 0;
            background-color: #667eea;
            transition: width 0.3s ease;
        }
        .link-underline:hover:after {
            width: 100%;
        }
        .drop-cap:first-letter {
            float: left;
            font-size: 3.5em;
            line-height: 0.85;
            padding: 0.1em 0.1em 0 0;
            color: #667eea;
            font-weight: bold;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 md:py-32 px-4 md:px-0">
        <div class="container mx-auto max-w-5xl text-center">
            <h1 class="text-4xl md:text-6xl font-bold mb-6 serif">深入理解 Java 异常</h1>
            <h2 class="text-2xl md:text-3xl font-medium mb-8">ExceptionInInitializerError 解析</h2>
            <p class="text-xl md:text-2xl opacity-90 max-w-3xl mx-auto">
                探索类静态初始化过程中的关键错误类型及其解决方案
            </p>
            <div class="mt-10">
                <a href="#content" class="inline-block bg-white text-indigo-700 font-semibold px-8 py-3 rounded-full hover:bg-gray-100 transition duration-300">
                    开始阅读 <i class="fas fa-arrow-down ml-2"></i>
                </a>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto max-w-5xl px-4 md:px-0 py-16" id="content">
        <!-- Introduction -->
        <section class="mb-16">
            <div class="drop-cap text-lg md:text-xl text-gray-700 leading-relaxed">
                <p><span class="font-bold text-indigo-600">ExceptionInInitializerError</span> 是 Java 中的一种错误类型，继承自 <code class="bg-gray-100 px-1 py-0.5 rounded">LinkageError</code>。它表示在类的静态初始化过程中发生了异常。这个错误通常是由于静态初始化块或静态字段初始化期间的异常导致的。</p>
            </div>
        </section>

        <!-- Use Cases Section -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 text-gray-800 serif border-b pb-2 flex items-center">
                <i class="fas fa-exclamation-triangle text-indigo-500 mr-3"></i>
                产生 ExceptionInInitializerError 的情况
            </h2>
            <p class="text-lg text-gray-700 mb-6"><code class="bg-gray-100 px-1 py-0.5 rounded">ExceptionInInitializerError</code> 是在类的初始化过程中发生的异常时抛出的。这种情况通常会在以下几种场景中发生：</p>
            
            <div class="grid md:grid-cols-2 gap-8 mb-10">
                <!-- Static Block Card -->
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <div class="flex items-center mb-4">
                            <div class="bg-indigo-100 p-3 rounded-full mr-4">
                                <i class="fas fa-code text-indigo-600 text-xl"></i>
                            </div>
                            <h3 class="text-xl font-bold text-gray-800">静态初始化块抛出异常</h3>
                        </div>
                        <p class="text-gray-600 mb-4">如果类的静态初始化块（<code>static</code> 块）抛出异常，JVM 会捕获这个异常并抛出 <code>ExceptionInInitializerError</code>。</p>
                        <div class="code-block p-4 rounded-lg">
                            <pre class="text-gray-200 text-sm overflow-x-auto"><code>public class Demo {
    static {
        // 这个静态块抛出异常
        throw new RuntimeException("Initialization error");
    }
}</code></pre>
                        </div>
                    </div>
                </div>
                
                <!-- Static Field Card -->
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <div class="flex items-center mb-4">
                            <div class="bg-indigo-100 p-3 rounded-full mr-4">
                                <i class="fas fa-list-ol text-indigo-600 text-xl"></i>
                            </div>
                            <h3 class="text-xl font-bold text-gray-800">静态字段初始化抛出异常</h3>
                        </div>
                        <p class="text-gray-600 mb-4">如果在类的静态字段初始化时发生异常，也会导致 <code>ExceptionInInitializerError</code>。</p>
                        <div class="code-block p-4 rounded-lg">
                            <pre class="text-gray-200 text-sm overflow-x-auto"><code>public class Demo {
    // 这个静态字段初始化时抛出异常
    static {
        int[] array = new int[5];
        array[10] = 1; // 数组下标越界
    }
}</code></pre>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Process Section -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 text-gray-800 serif border-b pb-2 flex items-center">
                <i class="fas fa-layer-group text-indigo-500 mr-3"></i>
                产生 ExceptionInInitializerError 的详细过程
            </h2>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-10">
                <div class="p-6 md:p-8">
                    <div class="flex flex-col md:flex-row">
                        <div class="md:w-1/2 pr-0 md:pr-8">
                            <h3 class="text-xl font-bold text-gray-800 mb-4">类加载与初始化流程</h3>
                            <ul class="space-y-4 text-gray-700">
                                <li class="flex items-start">
                                    <div class="bg-indigo-100 text-indigo-600 rounded-full w-6 h-6 flex items-center justify-center mr-3 flex-shrink-0">
                                        <span class="text-sm font-bold">1</span>
                                    </div>
                                    <span><strong>类加载</strong>：当一个类被加载到 JVM 中时，JVM 会执行类的静态初始化过程，包括执行静态字段的初始化和静态初始化块。</span>
                                </li>
                                <li class="flex items-start">
                                    <div class="bg-indigo-100 text-indigo-600 rounded-full w-6 h-6 flex items-center justify-center mr-3 flex-shrink-0">
                                        <span class="text-sm font-bold">2</span>
                                    </div>
                                    <span><strong>静态初始化</strong>：在执行静态初始化块或静态字段初始化时，如果发生了异常，JVM 会将这个异常包装在 <code>ExceptionInInitializerError</code> 中。</span>
                                </li>
                                <li class="flex items-start">
                                    <div class="bg-indigo-100 text-indigo-600 rounded-full w-6 h-6 flex items-center justify-center mr-3 flex-shrink-0">
                                        <span class="text-sm font-bold">3</span>
                                    </div>
                                    <span><strong>抛出异常</strong>：<code>ExceptionInInitializerError</code> 会被抛出，并且异常的原始原因会作为其 <code>getCause()</code> 方法的返回值。这有助于追踪导致初始化失败的实际原因。</span>
                                </li>
                            </ul>
                        </div>
                        <div class="md:w-1/2 mt-8 md:mt-0">
                            <div class="mermaid">
                                sequenceDiagram
                                    participant JVM
                                    participant ClassLoader
                                    participant StaticBlock
                                    participant ErrorHandler
                                    
                                    ClassLoader->>+JVM: 加载类
                                    JVM->>+StaticBlock: 执行静态初始化
                                    StaticBlock-->>-ErrorHandler: 抛出RuntimeException
                                    ErrorHandler->>+JVM: 包装为ExceptionInInitializerError
                                    JVM-->>-ClassLoader: 抛出ExceptionInInitializerError
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Example Section -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 text-gray-800 serif border-b pb-2 flex items-center">
                <i class="fas fa-code text-indigo-500 mr-3"></i>
                示例代码
            </h2>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-6 md:p-8">
                    <div class="code-block p-4 rounded-lg mb-6">
                        <pre class="text-gray-200 text-sm overflow-x-auto"><code>public class Demo {
    static {
        try {
            // 模拟初始化异常
            throw new RuntimeException("Initialization failure");
        } catch (Exception e) {
            // 捕获异常并重新抛出
            throw new ExceptionInInitializerError(e);
        }
    }
    
    public static void main(String[] args) {
        try {
            // 访问类以触发初始化
            Class.forName("Demo");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}</code></pre>
                    </div>
                    <div class="bg-blue-50 border-l-4 border-blue-400 p-4">
                        <div class="flex">
                            <div class="flex-shrink-0">
                                <i class="fas fa-info-circle text-blue-500 text-xl"></i>
                            </div>
                            <div class="ml-3">
                                <p class="text-blue-700">
                                    在这个例子中，当 <code>Demo</code> 类被加载时，静态初始化块会抛出 <code>RuntimeException</code>，这个异常被 <code>ExceptionInInitializerError</code> 包装并抛出。
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Summary Section -->
        <section class="mb-16 bg-indigo-50 rounded-xl p-8">
            <h2 class="text-2xl font-bold mb-6 text-indigo-800 serif flex items-center">
                <i class="fas fa-lightbulb text-indigo-600 mr-3"></i>
                关键要点
            </h2>
            <ul class="grid md:grid-cols-2 gap-6">
                <li class="flex items-start">
                    <div class="bg-indigo-100 text-indigo-600 rounded-full w-6 h-6 flex items-center justify-center mr-3 flex-shrink-0">
                        <i class="fas fa-check text-xs"></i>
                    </div>
                    <span class="text-gray-700"><code>ExceptionInInitializerError</code> 表示类初始化过程中的致命错误</span>
                </li>
                <li class="flex items-start">
                    <div class="bg-indigo-100 text-indigo-600 rounded-full w-6 h-6 flex items-center justify-center mr-3 flex-shrink-0">
                        <i class="fas fa-check text-xs"></i>
                    </div>
                    <span class="text-gray-700">通常由静态初始化块或静态字段初始化异常引起</span>
                </li>
                <li class="flex items-start">
                    <div class="bg-indigo-100 text-indigo-600 rounded-full w-6 h-6 flex items-center justify-center mr-3 flex-shrink-0">
                        <i class="fas fa-check text-xs"></i>
                    </div>
                    <span class="text-gray-700">原始异常可通过 <code>getCause()</code> 方法获取</span>
                </li>
                <li class="flex items-start">
                    <div class="bg-indigo-100 text-indigo-600 rounded-full w-6 h-6 flex items-center justify-center mr-3 flex-shrink-0">
                        <i class="fas fa-check text-xs"></i>
                    </div>
                    <span class="text-gray-700">属于 <code>LinkageError</code> 子类，表示类链接问题</span>
                </li>
            </ul>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-10">
        <div class="container mx-auto max-w-5xl px-4 md:px-0">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-semibold text-white mb-2">技术小馆</h3>
                    <a href="http://www.yuque.com/jtostring" target="_blank" class="text-indigo-300 hover:text-indigo-100 link-underline inline-block">
                        http://www.yuque.com/jtostring
                    </a>
                </div>
                <div class="flex space-x-4">
                    <a href="#" class="text-gray-400 hover:text-white transition duration-300">
                        <i class="fab fa-github text-xl"></i>
                    </a>
                    <a href="#" class="text-gray-400 hover:text-white transition duration-300">
                        <i class="fab fa-twitter text-xl"></i>
                    </a>
                    <a href="#" class="text-gray-400 hover:text-white transition duration-300">
                        <i class="fab fa-weixin text-xl"></i>
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-8 text-center text-sm text-gray-500">
                &copy; 2023 技术小馆. 保留所有权利.
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'dark',
            flowchart: {
                useMaxWidth: false,
                htmlLabels: true
            }
        });
        
        // 平滑滚动
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>
```